package com.face.gaoml.netlibrary.data.rusult;



import com.face.gaoml.netlibrary.data.exception.ApiErrorCode;
import com.face.gaoml.netlibrary.data.exception.ApiException;

import rx.functions.Func1;

/**
 * Created by gml on 16/12/14.
 * <p>
 * /**
 * 用来统一处理Http的resultCode,并将HttpResult的Data部分剥离出来返回给subscriber  数据剥离
 *
 * @param <T> Subscriber真正需要的数据类型，也就是Data部分的数据类型
 */

public class HttpResultFunc<T> implements Func1<BaseResult<T>, T> {


    @Override
    public T call(BaseResult<T> httpResult) {
        if (httpResult.getState().equals("false")) {
            throw new ApiException(ApiErrorCode.STATUS_FLASE, httpResult.getMsg());
        }
        return httpResult.getData();


    }
}